<!--suppress JSUnfilteredForInLoop -->
<template>
  <div>
    <ButtonBarRowComponent>
      <Button text="增加路径" :click-function="addInputNum"></Button>
      <Button text="减少路径" :click-function="subInputNum"></Button>
      <Button text="文件抓取" :click-function="textCopy1024"></Button>
      <Button text="重置" :click-function="reset"></Button>
    </ButtonBarRowComponent>
    <ToolBarComponent ref="down-tool-bar">
      <RadioGroupComponent ref="text-copyModuel-radion" radio-group-name="copyModuel" radio-group-item="抓取模式">
        <RedioComponent radio-item="独立抓取" radio-value="0"></RedioComponent>
        <RedioComponent radio-item="组合抓取" radio-value="1"></RedioComponent>
      </RadioGroupComponent>
      <InputComponent ref="input-title-div" :input-width="250" input-type="text" :input-lable="'文章名'" input-name="dirName"></InputComponent>
      <ToolBarComponent ref="down-load-bar">
        <div v-for="index in inputNum" :key="index">
          <LongInputComponent  ref="input-div" input-type="text" :input-name="index+''" :input-lable="'抓取路径'+index"></LongInputComponent>
        </div>
      </ToolBarComponent>
    </ToolBarComponent>
  </div>
</template>

<script>
import ButtonBarRowComponent from "@/components/button/ButtonBarRowComponent";
import Button from "@/components/button/ButtonComponent";
import LongInputComponent from "@/components/input/LongInputComponent";
import RadioGroupComponent from "@/components/input/RadioGroupComponent";
import RedioComponent from "@/components/input/RedioComponent";
import {postRequest} from "@/axio2";
import InputComponent from "@/components/input/InputComponent";
import ToolBarComponent from "@/components/toolbar/ToolBarComponent";

export default {
  name: "CopyText1024Page",
  components: {
    ToolBarComponent,
    InputComponent, RedioComponent, RadioGroupComponent, LongInputComponent, Button, ButtonBarRowComponent},
  data(){
    return{
      inputNum:0,
      inputString:new Map,
      articalName:""
    }
  },
  methods:{
    addInputNum:function (){
      this.inputNum = this.inputNum + 1;
    },
    subInputNum:function (){
      this.inputNum = this.inputNum - 1;
    },
    textCopy1024:function (){
      if(0===this.inputNum){
        alert("路径不能为空");
        return;
      }
      let param = this.$refs["down-tool-bar"].getSubmitParams();
      let pathParam = this.$refs["down-load-bar"].getSubmitParams();
      let pathArr = "";
      param["targetSite"]="http://y11.vtx9c.net/pw/";
      for(let pathKey in pathParam){
        pathArr = pathArr+pathParam[pathKey].replace(param["targetSite"],"") + ",";
      }
      pathArr = pathArr.substr(0, pathArr.length-1);
      param["path"] = pathArr;
      postRequest(
          '1024/imgCopy.do',
          param,
          this.copySuccessCallBack,
          null,
          this
      );
    },
    copySuccessCallBack:function (data,component) {
      component.reset();
    },
    reset:function (){
      this.inputNum = 0;
      this.inputString = new Map;
      this.articalName = "";
    }
  }
}
</script>

<style scoped>

</style>